package com.yfqy.app.modules.integral.resource;

import com.yfqy.app.domain.vo.ResultVO;
import com.yfqy.app.modules.integral.service.SignService;
import com.yfqy.app.modules.integral.vo.SignInResultVO;
import com.yfqy.app.modules.system.dto.SignInRewardDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 客户端用户签到，领积分
 */
@RestController
@RequestMapping("/api/client/integral")
public class SignInController {

    @Autowired
    private SignService integralService;

    /**
     * 用户连续签到
     *
     * @return
     */
    @PostMapping("/signIn")
    public ResultVO<SignInResultVO> signIn() {
        SignInResultVO points = integralService.processDailySignIn();
        return ResultVO.data(points);
    }

    /**
     * 获取用户本月签到情况
     *
     * @return
     */
    @GetMapping("/getMonthSignInRecords")
    public ResultVO<List<String>> getMonthSignInRecords() {
        List<String> monthSignInRecords = integralService.getMonthSignInRecords();
        return ResultVO.data(monthSignInRecords);
    }

    /**
     * 获取用户连续签到天数
     *
     * @return
     */
    @GetMapping("/getContinuousDays")
    public ResultVO<Integer> getContinuousDays() {
        int continuousDays = integralService.getContinuousDays();
        return ResultVO.data(continuousDays);
    }

    /**
     * 连续签到配置
     *
     * @return
     */
    @GetMapping("/signConfig")
    public ResultVO<SignInRewardDTO> signConfig() {
        return ResultVO.data(integralService.signConfig());
    }

}
